From 64d80c8cac65d7507cab69f6b9aac04c2f44fb1b Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Mon, 16 Aug 2004 18:08:07 +0000 Subject: [PATCH] bitkeeper revision 1.1159.34.1 (4120f807tIRvdXAnGlpEWbbgD_eByQ) Speed up the context-switch path on 2.6. --- .rootkeys | 1 + .../arch/xen/i386/kernel/process.c | 7 +- .../include/asm-xen/asm-i386/mmu_context.h | 75 +++++++++++++++++++ .../include/asm-xen/asm-i386/processor.h | 5 ++ 4 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/mmu_context.h diff --git a/.rootkeys b/.rootkeys index a98b088629..f03b2039ec 100644 --- a/.rootkeys +++ b/.rootkeys @@ -218,6 +218,7 @@ 41062ab7HMSSuaUv3_Z4agLpjSO88A linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/mach-xen/pci-functions.h 40f5623aDMCsWOFO0jktZ4e8sjwvEg linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/mach-xen/setup_arch_post.h 40f5623arsFXkGdPvIqvFi3yFXGR0Q linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/mach-xen/setup_arch_pre.h +4120f807GCO0uqsLqdZj9csxR1Wthw linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/mmu_context.h 40f5623aFTyFTR-vdiA-KaGxk5JOKQ linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/msr.h 40f5623adgjZq9nAgCt0IXdWl7udSA linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/page.h 40f5623a54NuG-7qHihGYmw4wWQnMA linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/param.h diff --git a/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/process.c b/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/process.c index da60123dfd..f519ba1c5e 100644 --- a/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/process.c +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/process.c @@ -502,10 +502,10 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas *next = &next_p->thread; int cpu = smp_processor_id(); struct tss_struct *tss = init_tss + cpu; - unsigned long flags; dom0_op_t op; - local_irq_save(flags); + /* NB. No need to disable interrupts as already done in sched.c */ + /* __cli(); */ /* * Save away %fs and %gs. No need to save %es and %ds, as @@ -569,8 +569,7 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas /* EXECUTE ALL TASK SWITCH XEN SYSCALLS AT THIS POINT. */ execute_multicall_list(); - - local_irq_restore(flags); + /* __sti(); */ /* * Restore %fs and %gs if needed. diff --git a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/mmu_context.h b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/mmu_context.h new file mode 100644 index 0000000000..cea0fd614c --- /dev/null +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/mmu_context.h @@ -0,0 +1,75 @@ +#ifndef __I386_SCHED_H +#define __I386_SCHED_H + +#include +#include +#include +#include +#include + +/* + * Used for LDT copy/destruction. + */ +int init_new_context(struct task_struct *tsk, struct mm_struct *mm); +void destroy_context(struct mm_struct *mm); + + +static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) +{ +#ifdef CONFIG_SMP + unsigned cpu = smp_processor_id(); + if (cpu_tlbstate[cpu].state == TLBSTATE_OK) + cpu_tlbstate[cpu].state = TLBSTATE_LAZY; +#endif +} + +static inline void switch_mm(struct mm_struct *prev, + struct mm_struct *next, + struct task_struct *tsk) +{ + int cpu = smp_processor_id(); + + if (likely(prev != next)) { + /* stop flush ipis for the previous mm */ + cpu_clear(cpu, prev->cpu_vm_mask); +#ifdef CONFIG_SMP + cpu_tlbstate[cpu].state = TLBSTATE_OK; + cpu_tlbstate[cpu].active_mm = next; +#endif + cpu_set(cpu, next->cpu_vm_mask); + + /* Re-load page tables */ + load_cr3_noflush(next->pgd); + + /* + * load the LDT, if the LDT is different: + */ + if (unlikely(prev->context.ldt != next->context.ldt)) + load_LDT_nolock(&next->context, cpu); + } +#ifdef CONFIG_SMP + else { + cpu_tlbstate[cpu].state = TLBSTATE_OK; + BUG_ON(cpu_tlbstate[cpu].active_mm != next); + + if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) { + /* We were in lazy tlb mode and leave_mm disabled + * tlb flush IPI delivery. We must reload %cr3. + */ + load_cr3_noflush(next->pgd); + load_LDT_nolock(&next->context, cpu); + } + } +#endif +} + +#define deactivate_mm(tsk, mm) \ + asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0)) + +#define activate_mm(prev, next) \ +do { \ + switch_mm((prev),(next),NULL); \ + flush_page_update_queue(); \ +} while ( 0 ) + +#endif diff --git a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/processor.h b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/processor.h index a57533dd8a..b4eafd19f7 100644 --- a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/processor.h +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/processor.h @@ -186,6 +186,11 @@ static inline unsigned int cpuid_edx(unsigned int op) cur_pgd = pgdir; /* XXXsmp */ \ } while (/* CONSTCOND */0) +#define load_cr3_noflush(pgdir) do { \ + queue_pt_switch(__pa(pgdir)); \ + cur_pgd = pgdir; /* XXXsmp */ \ +} while (/* CONSTCOND */0) + /* * Intel CPU features in CR4 -- 2.30.2